﻿
<!DOCTYPE html>
<html>
<!-- 培训成绩单-导入 -->

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

    <style>
        .lineMust {
            position: absolute;
            right: 15px;
            bottom: 2px;
            bottom: 3px\0 !important;
            /* 兼容ie */
        }
    </style>
</head>

<body>
    <div id="app" class="popupW100" v-cloak>
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px"
                 size="mini">
            <el-row>

                <!--培训课程-->
                <el-col :span="24">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item prop="trainingcourse">
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{TrainingPlanManagement.trainingcourse+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.trainingcourse" slot="suffix"
                                               :placeholder="TrainingPlanManagement.trainingcourse">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in trainingcourseArray" :label="item.value" :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>


                <!--培训时间-->
                <el-col :span="24">
                    <el-form-item prop="Trainingtime">
                        <div class="elst-select-mini" style="margin-left: -100px">
                            <el-input size="mini">
                                <template slot="prepend">
                                    {{TrainingPlanManagement.Trainingtime+mark.m}}
                                </template>
                                <el-date-picker slot="suffix" v-model="Form.Trainingtime" type="date" size="mini"
                                                format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择时间">
                                </el-date-picker>
                            </el-input>
                        </div>
                        <span class="lineMust" v-if="Form.Trainingtime.length<=0">
                            <!-- 必填项添加 -->
                            <img src="/static/images/exclamation.png" alt="">
                        </span>
                    </el-form-item>
                </el-col>


                <!--培训成绩单-->
                <el-col :span="24">
                    <div class="elst-select-mini">
                        <label class="el-form-item__label">成绩单</label>
                        <label class="fl" style="margin: 10px 10px 0 0;">{{Form.CheckInForm}}</label>
                        <!-- <btn-uploadfile-list text="ccc" url="xxxx"></btn-uploadfile-list> -->
                        <el-upload ref="Attachmentupload" action="/api/File/UpdateFile" multiple="true"
                                   :on-preview="handlePreview" :on-remove="handleRemove"
                                   :before-upload="CoursewareUploadbeforeupload" :auto-upload="true" :limit="1"
                                   :show-file-list="false">
                            <el-button style="    margin: 5px;" type="primary" size="mini" @click="btnAttachmentUpload">
                                选择
                            </el-button>
                        </el-upload>
                    </div>
                </el-col>




            </el-row>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <!--<el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>-->
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
        <!--user建议替换为表名 需要与resource文件夹下js 中的对象保持一致  -->
        <el-dialog :title="title" fullscreen="true" :visible.sync="ListItem.dialogVisible" @close='closeDialog'
                   width="80%" height="80%" top="10vh">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:100%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">
        var uploadText = "请选择上传文件";
        var app = new Vue({
            el: '#app',
            data: {
                //父业传参
                id: '',
                title: '',
                imageUrl: '',

                value1: '',
                radio: '1',
                ListItem: ListItem,

                trainingcourseArray:[], //培训课程
                postArray: [],
                TrainingMatrix: [],
                mastery: [],//掌握程度
                Trainingmethods: [],
                facilityvalue: [],
                Questiontype: [],
                Examinationmethods: [],
                formInline: {
                    model: {
                        PersonnelName: '',
                        Subordinatedepartments: '',
                        Nameofcertificate: '',
                        Issuancetime: '',
                        Maturitytime: '',
                        Certificatetype: '',
                        LicenseCoding: '',
                        Licensingauthority: '',
                        Termofvalidity: '',
                        Trainer: ''
                    },
                    offset: 0,
                    limit: 10
                },
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    Trainingtime: '',
                    trainingcourse: '', // uploadText,

                    CheckInForm: uploadText,// uploadText,//签到表

                    Trainingvenues: '',
                    Typesoftraining: '',
                    Trainingcontent: '',
                    state: '',
                    Trainer: '',
                    HeadofTraining: '',
                    Nameoftrainingplan: '',
                    TrainingMatrix: '',
                    Trainingbudget: '',
                    mastery: '',//掌握程度
                    Trainingmethods: '',
                    Trainers: [],
                    facilityvalue: '',
                    Questiontype: '',
                    Fullmarks: '',
                    Qualificationscore: '',
                    JudgmentQuestion: '',
                    Scoresforeachquestion1: '',
                    Singlechoicetopic: '',
                    Scoresforeachquestion2: '',
                    Multipletopics: '',
                    Scoresforeachquestion3: '',
                    Examinationstarttime: '',
                    Endtimeofexamination: '',
                    Examinationmethods: '',

                    Trainingobjectives: '',//培训目标
                },
                //表单验证
                rules: {
                    trainingcourse: [
                        verification.NotNull,
                    ],
                    Trainingvenues: [
                        verification.NotNull,
                    ],
                    Trainingtime: [
                        verification.NotNull,
                    ],

                }
            },

            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                handleRemove: function (file) {
                    console.log(file);
                },
                handlePreview: function (file) {
                    console.log(file.name);
                    window.open(file.url)
                },
                //上传附件文件的校验
                CoursewareUploadbeforeupload: function (file) {
                    var testmsg = file.name.substring(file.name.lastIndexOf('.') + 1)
                    //将附件名赋值到label上
                    //this.Form.trainingcourse = file.name;
                    this.Form.CheckInForm = file.name;
                    const extension = testmsg === 'doc'
                    const extension2 = testmsg === 'pdf'
                    const isLt10M = file.size / 1024 / 1024 < 10
                    if (!extension && !extension2) {
                        this.$message({
                            message: '上传文件只能是 doc、pdf格式!',
                            type: 'warning'
                        });
                    }
                    if (!isLt10M) {
                        this.$message({
                            message: '上传文件大小不能超过 10MB!',
                            type: 'warning'
                        });
                    }
                    if (extension || extension2 && isLt10M)
                        submitUpload(this, 'upload')
                    return extension || extension2 && isLt10M
                },
                btnAttachmentUpload: function () {
                    //若更换文件则将文件名字更换触发条件--先删除上一个文件,后添加一个文件
                    if (this.fileAttachmentUpload != uploadText) {
                        this.$refs.Attachmentupload.clearFiles();
                        this.fileAttachmentUpload = file.name;
                    }
                    else {

                    }
                    this.$refs.Attachmentupload.submit();
                },
                //获取分页数据
                GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/TrainingPlanManagement/GetList') },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                btnUpLoad: function () {
                    this.$message({
                        message: '上传成功',
                        type: 'success'
                    });
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            //onSubmitForm(this, '/api/TrainingPlanManagement/Save', mythis.Form);
                            parent.ListItem.dialogVisible = false;
                        } else {
                            //验证失败
                            showMessage(msg.NoMust, 'error');
                            return false;
                        }
                    });
                },
                getData: function () {
                    getData(this, '/api/TrainingPlanManagement/get?id=' + this.id);
                },

                //删除方法
                onDelete: function () { onDelete(this, '/api/TrainingPlanManagement/DeleteMuti'); },
                //列表选择触发
                UserInputStatistics: function (val, id) { DialogShow(this, val, "TrainingPlanManagementInputPerson.html", id); },
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //获取分页数据
                GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/TrainingPlanManagement/GetList') },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
                addTrainer: function (val, id) {
                    this.title = '选择培训老师';
                    DialogShow(this, val, "TrainingPlanManagementluruInputTrainer.html", id);
                },
                //addTrainers: function (val, id) {
                //    this.title = '选择培训人员';
                //    DialogShow(this, val, "TrainingPlanManagementluruInputTrainers.html", id);
                //},
                addTrainers: function (val, id) {
                    this.title = '选择目标人群';
                    DialogShow(this, val, "TrainingPlanManagementluruInputTrainers.html", id);
                },

            },
            mounted: function () {
                //初始化数据
                this.GetPageData(1);
                //列表高度自适应
                tablehigh(this);
                this.id = getUrlParam("id");
                this.getData();
                //获取下拉菜单内容
                this.TrainingMatrix = getDicData('n93');
                this.Trainingmethods = getDicData('w64');//培训方式
                this.facilityvalue = getDicData('55');
                this.Questiontype = getDicData('28');
                this.Examinationmethods = getDicData('w64');
                this.postArray = getDicData('60');//岗位
                this.mastery = getDicData('Mastery1');//掌握程度

                this.trainingcourseArray = getDicData('54');//培训课程
            }

        });
    </script>
</body>

</html>